package org.ktpro.shortlink.project.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
import org.ktpro.shortlink.project.dao.entity.ShortLinkDO;
import org.ktpro.shortlink.project.dto.biz.ShortLinkStatsRecordDTO;
import org.ktpro.shortlink.project.dto.req.ShortLinkBatchCreateReqDTO;
import org.ktpro.shortlink.project.dto.req.ShortLinkCreateReqDTO;
import org.ktpro.shortlink.project.dto.req.ShortLinkPageReqDTO;
import org.ktpro.shortlink.project.dto.req.ShortLinkUpdateReqDTO;
import org.ktpro.shortlink.project.dto.resp.ShortLinkBatchCreateRespDTO;
import org.ktpro.shortlink.project.dto.resp.ShortLinkCreateRespDTO;
import org.ktpro.shortlink.project.dto.resp.ShortLinkGroupCountQueryRespDTO;
import org.ktpro.shortlink.project.dto.resp.ShortLinkPageRespDTO;

import java.io.IOException;
import java.util.List;

/**
 * 短链接接口层
 *
 * @Author Kris20030907
 * QQ: 3185633428 微信: 18712679036
 */
public interface ShortLinkService extends IService<ShortLinkDO> {

    /**
     * 创建短链接
     *
     * @param requestParam 短链接创建请求实体
     * @return 短链接创建返回实体
     */
    ShortLinkCreateRespDTO create(ShortLinkCreateReqDTO requestParam);

    /**
     * 短链接分页查询
     */
    IPage<ShortLinkPageRespDTO> pageShortLink(ShortLinkPageReqDTO requestParam);

    /**
     * 分组内短链接数量查询
     */
    List<ShortLinkGroupCountQueryRespDTO> listGroupShortLinkCount(List<String> requestParam);

    /**
     * 修改短链接接口
     */
    void updateShortLink(ShortLinkUpdateReqDTO requestParam);

    /**
     * 短链接统计接口
     */
    void shortLinkStats(String fullShortUrl, String gid, ShortLinkStatsRecordDTO statsRecord);

    /**
     * 短链接重定向接口
     *
     * @param shortUri 短链接
     * @param request  客户端请求
     * @param response 服务端响应
     */
    void restoreUrl(String shortUri, ServletRequest request, ServletResponse response) throws IOException;

    /**
     * 批量创建短链接
     */
    ShortLinkBatchCreateRespDTO batchCreateShortLink(ShortLinkBatchCreateReqDTO requestParam);
}
